import router, { varRoutes, constantRoutes } from '@/router'

const state = {
  routes: [], // 全部路由用于侧边栏
  // 按钮权限
  points: {
    pointUserUpdate: 'point-user-update',
    pointUserDelete: 'POINT-USER-delete',
    pointUserEdit: 'POINT-USER-edit',
    pointUserJob: 'POINT-USER-job',
    // 权限页面的权限标识
    pointPermissionAdd: 'point-permission-add',
    pointPermissionDelete: 'point-permission-delete'
  }
}
const mutations = {
  // 筛选所有路由并储存到vuex里
  filterRoutes(state, menus) {
    const filterVarRoutes = varRoutes.filter(item => menus.includes(item.name))
    const router404 = { path: '*', redirect: '/404', hidden: true }
    router.addRoutes([...filterVarRoutes, router404])
    state.routes = [...constantRoutes, ...filterVarRoutes]
  }
}
const actions = {}
export default {
  namespaced: true,
  state,
  mutations,
  actions
}
